from test_platform.base import Base

# 封装测试用例接口
class TestCase(Base):
    BASE_URL = "http://localhost:5000/"
    def create(self, nodeid, description):
        data = {
            "nodeid": nodeid,
            "description": description
        }
        url = self.BASE_URL + "/testcase/add"
        r = self.send("POST", url, json=data)
        # return r.text
        return r.json()

    def get(self, nodeid):
        url = self.BASE_URL + f"/testcase/get?nodeid={nodeid}"
        r = self.send("GET", url)
        return r.json()

    def update(self, nodeid, description):
        data = {
            "nodeid": nodeid,
            "description": description
        }
        url = self.BASE_URL + "/testcase/update"
        r = self.send("POST", url, json=data)
        # return r.text
        return r.json()

    def delete(self, nodeid):
        url = self.BASE_URL + f"/testcase/delete?nodeid={nodeid}"
        r = self.send("GET", url)
        return r.json()